# -*- coding: UTF-8 -*-
"""
@auth:buxiangjie
@date:2023/1/31 09:56
@describe: http请求
"""

import json
import traceback

import requests

from util.common import Common
from requests.models import Response

CONFIG = Common().read_yaml_data("config", "config.yaml")


class Req:
	pass

	@staticmethod
	def req(env: str = "saas_test", **kwargs) -> Response:
		base_url = CONFIG["env"][env]
		try:
			rep = requests.post(
				url=base_url + kwargs["path"],
				headers=kwargs["headers"],
				data=json.dumps(kwargs["param"], ensure_ascii=False).encode("utf-8")
			)
			return rep
		except Exception:
			raise SystemError(traceback.extract_stack())
